{extend name='index/index' /}
{block name='main'}
<div class="tpl-content-wrapper">
    <div class="tpl-content-page-title">
        Amaze UI 管理员列表
    </div>
    <ol class="am-breadcrumb">
        <li><a href="{:url('admin/index/index')}" class="am-icon-home">首页</a></li>
        <li><a href="#">Manager管理</a></li>
        <li class="am-active">管理员列表</li>
    </ol>
    <div class="tpl-portlet-components">
        <div class="portlet-title">
            <div class="caption font-green bold">
                <span class="am-icon-code"></span> 列表
            </div>
            <!--<div class="tpl-portlet-input tpl-fz-ml">-->
                <!--<div class="portlet-input input-small input-inline">-->
                    <!--<div class="input-icon right">-->
                        <!--<i class="am-icon-search"></i>-->
                        <!--<input type="text" class="form-control form-control-solid" placeholder="搜索..."></div>-->
                <!--</div>-->
            <!--</div>-->


        </div>
        <div class="tpl-block">
            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <button type="button" class="am-btn am-btn-default am-btn-success"><span
                                    class="am-icon-plus"></span> <a href="{:url('admin/manager/create')}" >新增</a>
                            </button>
                            <!--<button type="button" class="am-btn am-btn-default am-btn-secondary"><span-->
                                    <!--class="am-icon-save"></span> 保存-->
                            <!--</button>-->
                            <!--<button type="button" class="am-btn am-btn-default am-btn-warning"><span-->
                                    <!--class="am-icon-archive"></span> 审核-->
                            <!--</button>-->
                            <!--<button type="button" class="am-btn am-btn-default am-btn-danger"><span-->
                                    <!--class="am-icon-trash-o"></span> 删除-->
                            <!--</button>-->
                        </div>
                    </div>
                </div>
                <!--<div class="am-u-sm-12 am-u-md-3">-->
                    <!--<div class="am-form-group">-->
                        <!--<select data-am-selected="{btnSize: 'sm'}">-->
                            <!--<option value="option1">所有类别</option>-->
                            <!--<option value="option2">IT业界</option>-->
                            <!--<option value="option3">数码产品</option>-->
                            <!--<option value="option3">笔记本电脑</option>-->
                            <!--<option value="option3">平板电脑</option>-->
                            <!--<option value="option3">只能手机</option>-->
                            <!--<option value="option3">超极本</option>-->
                        <!--</select>-->
                    <!--</div>-->
                <!--</div>-->
                <!--<div class="am-u-sm-12 am-u-md-3">-->
                    <!--<div class="am-input-group am-input-group-sm">-->
                        <!--<input type="text" class="am-form-field">-->
                        <!--<span class="am-input-group-btn">-->
            <!--<button class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search"-->
                    <!--type="button"></button>-->
          <!--</span>-->
                    <!--</div>-->
                <!--</div>-->
            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form">
                        <table class="am-table am-table-striped am-table-hover table-main">
                            <thead>
                            <tr>
                                <th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>
                                <th class="table-id">ID</th>
                                <th class="table-title">名称</th>
                                <th class="table-type">状态</th>

                                <th class="table-date am-hide-sm-only">修改日期</th>
                                <th class="table-set">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name='user_list' id='val'}
                            <tr>
                                <td><input type="checkbox"></td>
                                <td>{$val['manager_id']}</td>
                                <td><a href="#">{$val['name']}</a></td>
                                <td>{$val['status'] ? '普通管理员' : '超级管理员' }</td>

                                <td class="am-hide-sm-only">{:date('Y-m-d H:i:s', $val['addtime'])}</td>
                                <td>
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <button id="mymodal" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span
                                                    class="am-icon-pencil-square-o"></span> <a href="manager/{$val['manager_id']}/edit">编辑</a>
                                            </button>
                                            <!------  模态框   ------>
                                            <!-- Button trigger modal -->


                                            <!--   模态框     -->
                                            <button class="am-btn am-btn-default am-btn-xs am-hide-sm-only"><span
                                                    class="am-icon-copy"></span> 复制
                                            </button>
                                            <button dataId="{$val['manager_id']}"
                                                    class="btn-del am-btn am-btn-default am-btn-xs am-text-danger ">
                                                <span class="am-icon-trash-o "></span> 删除
                                            </button>

                                        </div>
                                    </div>
                                </td>
                            </tr>
                            {/volist}

                            </tbody>
                        </table>
                        <div class="am-cf">

                            <div class="am-fr">
                                <ul class="am-pagination tpl-pagination" id="page">
                                    {$page}
                                    <!--<li class="am-disabled"><a href="#">«</a></li>-->
                                    <!--<li class="am-active"><a href="#">1</a></li>-->
                                    <!--<li><a href="#">2</a></li>-->
                                    <!--<li><a href="#">3</a></li>-->
                                    <!--<li><a href="#">4</a></li>-->
                                    <!--<li><a href="#">5</a></li>-->
                                    <!--<li><a href="#">»</a></li>-->
                                </ul>
                            </div>
                        </div>
                        <hr>

                    </form>
                </div>

            </div>
        </div>
        <div class="tpl-alert"></div>
    </div>


</div>

</div>
{/block}



{block name='myjs'}
<script>


    $(".menu_list").removeClass("active").removeClass("nav-link");
    $(".manager_list").addClass("active");


    // 分页左浮动
    $(".pagination>li").css("float", "left");

    // 设置弹框参数
    toastr.options = {
        closeButton: true,//是否显示关闭按钮
        progressBar: true,//实现显示计时条
        timeOut: "3000",//自动关闭时间
        positionClass: "toast-top-full-width"//提示位置
        // toast-top-full-width 顶端，宽度铺满整个屏幕
        // toast-top-right  顶端右边
    };

    // 删除管理员
    $(".btn-del").on('click', function () {
        var id = $(this).attr('dataId');

        $.ajax({
            type: 'delete', // DELETE请求方式
            url: '/admin/manager/' + id,
            dataType: 'json',
            success: function (data) {
                if (data)
                {
                    alert('删除成功');
                    $(this).parents('tr').remove();
//                    toastr.success('删除成功');
                }else{
//                    toastr.error('删除失败，请重试');
                    alert('删除失败，请重试');
                }

            },
            error: function () {
                // AJAX操作失败
                alert('AJAX操作失败');
            }
        });

        return false;
    } );


</script>
{/block}
